package com.yakami.ocean.view.fragment;

import android.widget.TextView;

import com.yakami.ocean.R;
import com.yakami.ocean.adapter.DynamicNewsAdapter;
import com.yakami.ocean.event.Event;
import com.yakami.ocean.view.fragment.base.BaseNewsListFragment;

import butterknife.Bind;

/**
 * @author Yakami, Created on 2016/4/19
 */
public class NestedNewsListFragment extends BaseNewsListFragment {

    //用于记录需要发送的事件类型，用于主页recyclerview的高度动态调整
    private Event.EventType mEventType;
    @Bind(R.id.load_error) TextView mLoad;

    @Override
    public void afterCreateView() {
        mRecyclerView.setNestedScrollingEnabled(false);
        DynamicNewsAdapter adapter = (DynamicNewsAdapter) mAdapter;
        adapter.setReturnedEvent(mEventType);
        //设置加载提示的边距
        mLoad.post(() -> {
           mLoad.setPadding(0, 5, 0, 5);
        });
        refresh();
    }

    @Override
    public void initAdapter() {
        mAdapter = new DynamicNewsAdapter(mAppContext);
    }

    public void setReturnedEventType(Event.EventType type) {
        mEventType = type;
    }

}
